// 创建路由  配置路由规则  导出路由实例对象
import Vue from 'vue'
//1.下载vue-router
//2.导入vue-router
import VueRouter from 'vue-router'
//3.使用VueRouter
Vue.use(VueRouter)
//4.创建路由数组
const routes = [
    {
        path: '/',
        redirect: '/layout',
    },
    {
        path: '/layout',
        component: Layout,
        redirect: '/layout/home',
        children: [
            {
                path: 'home',
                component: Home,
                //可以在路由上添加额外的信息
                meta: {
                    title: '首页'
                }
            }, {
                path: 'search',
                component: Search,
                meta: {
                    title: '搜索'
                }
            },
        ]

    },
    {
        path: '/play',
        component: Play,
    },
]
//5.创建路由对象
const router = new VueRouter({
    routes,
})
//6.将路由对象挂载到vue身上(不在一个组件里，需要将router对象导出去)
export default router

// 导入页面
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Search from '@/views/Search'
import Play from '@/views/Play'
